/*
 * Copyright 2008 Neil Bacon
 * Distributed under the terms of the Mozilla Public License version 1.1
 * or the GNU General Public License version 3.
 */

package nb.xadd.operator.impl;

import nb.cache.CacheMap;
import nb.xadd.NotYetImplemented;
import nb.xadd.node.Node;
import nb.xadd.node.NodeFactory;
import nb.xadd.node.impl.ConstantValueNode;
import nb.xadd.node.impl.LinearValueNode;
import nb.xadd.node.impl.PolynomialValueNode;

/**
 * Maximum - only ConstantValueNodes are handled, other types of terminal nodes
 * will throw MDPNotYetImplemented.
 */
public class BinaryMaximum extends AbstractBinaryOperator {

    protected BinaryMaximum(NodeFactory nodeFactory, CacheMap<ApplyCacheKey, Node> applyCache) {
        super(nodeFactory, applyCache);
    }

    @Override
    protected boolean isNoOp(ConstantValueNode c) {
        return false;
    }

    @Override
    public Node executeConstantConstant(ConstantValueNode n1, ConstantValueNode n2) {
        return n1.getConstValue() >= n2.getConstValue() ? n1 : n2;
    }

    @Override
    public Node executeConstantLinear(ConstantValueNode n1, LinearValueNode n2) {
        throw new NotYetImplemented();
    }

    @Override
    public Node executeConstantPolynomial(ConstantValueNode n1, PolynomialValueNode n2) {
        throw new NotYetImplemented();
    }

    @Override
    public Node executeLinearLinear(LinearValueNode n1, LinearValueNode n2) {
        throw new NotYetImplemented();
    }

    @Override
    public Node executeLinearPolynomial(LinearValueNode n1, PolynomialValueNode n2) {
        throw new NotYetImplemented();
    }

    @Override
    public Node executePolynomialPolynomial(PolynomialValueNode n1, PolynomialValueNode n2) {
        throw new NotYetImplemented();
    }

}
